FROM python:3.9-slim-bullseye

RUN printf 'deb [trusted=yes] http://mirrors.ustc.edu.cn/debian bullseye main contrib non-free\ndeb [trusted=yes] http://mirrors.ustc.edu.cn/debian bullseye-backports main contrib non-free\n' > /etc/apt/sources.list && \
    printf 'APT::Install-Recommends "false";\nAPT::Install-Suggests "false";\n' > /etc/apt/apt.conf.d/no-recommends-suggests && \
    apt-get -o "Acquire::https::Verify-Peer=false" update && \
    apt-get -o "Acquire::https::Verify-Peer=false" install -y ca-certificates && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* && \
    sed -i 's/http:/https:/g' /etc/apt/sources.list


RUN apt-get update
RUN apt-get install -y libgomp1 libgl1 libglib2.0-0

RUN pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple

RUN pip install --no-cache-dir gevent
RUN pip install --no-cache-dir paddlepaddle==2.4.0rc0
RUN pip install --no-cache-dir paddleocr==2.6.0

RUN apt install -y curl

EXPOSE 5000

COPY /hocr.py /opt/hocr/hocr.py

ENTRYPOINT [ "python3", "/opt/hocr/hocr.py" ]
